const ordersDao = require("../dao/ordersDao");

exports.getList = async (req, res) => {
  const orders = await ordersDao.getAll();
  res.json(orders);
};

exports.add = async (req, res) => {
  const order = req.body;
  const result = await ordersDao.add(order);
  res.json({ code: 200, message: "添加成功", order: result });
};

exports.update = async (req, res) => {
  const { id } = req.params;
  const order = req.body;
  const result = await ordersDao.update(id, order);
  res.json({ code: 200, message: "更新成功", order: result });
};

exports.remove = async (req, res) => {
  const { id } = req.params;
  await ordersDao.remove(id);
  res.json({ code: 200, message: "删除成功" });
};
